#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2023/9/21 10:03
# @Author : 闫峰
# @File    : ceshi1.py
import json
import threading
import time
from datetime import datetime

import pymongo

from utils.mysqlUtils.mongodb_utils import MongoDBLink
import os

from common.setting import ensure_path_sep
from utils.logging_tool.log_control import LogHandler
from utils.mysqlUtils.db_pool import Database
from utils.mysqlUtils.sql_server_utils import MSSQL
from concurrent.futures import ThreadPoolExecutor, wait, as_completed
from functools import partial

current_path = os.path.abspath(__file__)
current_dir = os.path.dirname(current_path)
path_list = current_path.split("\\")
dis_path = "\\".join(path_list[-2:-1])


def remove_file(info_path):
    if os.path.exists(info_path):
        os.remove(info_path)
    else:
        print(f"{info_path} 不存在")


info_path = ensure_path_sep(f"\\logs\\info-{dis_path}{time.time()}")
error_path = ensure_path_sep(f"\\logs\\\error-{dis_path}{time.time()}.log")
warning_path = ensure_path_sep(f"\\logs\\warning-{dis_path}{time.time()}.log")
remove_file(info_path)
remove_file(error_path)
remove_file(warning_path)
INFO = LogHandler(info_path, level='info')
ERROR = LogHandler(error_path, level='error')
WARNING = LogHandler(warning_path, level='warning')


class TestChange:
    mapping = {
        "packageLength": "Length",
        "packageWidth": "Width",
        "packageHeight": "Height"
    }

    def test_allocation_bill(self, AddTime_start, AddTime_end):
        erp_db = MSSQL(ensure_path_sep("\\config\\config.yaml"), "sqlserver_db_erp_base")
        # mysql_db = Database(ensure_path_sep("\\testcases\\erp\\responsible_inventory\\config.yaml"),
        #                     "irobotbox_datacenter")
        insert_db = Database(ensure_path_sep("\\config\\ceshi_mysql_config.yaml"), "log_db")
        # 遍历RB_Inventory_DetailLog库，验证allocation_bill
        get_BillNumber = f"""
        SELECT TOP 5000 BillNumber,OriginBillNumber,WareHouseID,SKU,id,CustomerID,AddTime,BillType 
        FROM [dbo].[RB_Inventory_DetailLog] 
        
        WHERE AddTime >= '{AddTime_start}' AND AddTime<='{AddTime_end}' AND CustomerID=1
        and id > %s order by id
        """

        id_offset = 0
        count = 0
        while True:
            res = erp_db.ExecQuery(get_BillNumber, (id_offset,))

            if res:
                id_offset = res[-1][4]
                # 过滤得到需要同步的数据
                res = list(filter(
                    lambda x: x[2] not in [8197, 10095, 8206, 8207, 8208, 9774, 9775, 8223, 9776, 8228, 9777, 9778,
                                           9779, 8243, 9780, 10097, 9782, 9783, 8269, 9785, 9786, 9787, 9789, 9790,
                                           9791, 8303, 8304, 8305, 10099, 9792, 9793, 9794, 9795, 9796, 9797, 8342,
                                           9799, 9807, 9808, 8391, 8408, 8410, 9814, 9815, 9816, 8428, 8429, 9817, 9818,
                                           9821, 8455, 8459, 8460, 8461, 9823, 9824, 9825, 9826, 9827, 8493, 9831, 8507,
                                           8518, 8520, 8521, 8522, 8523, 9836, 9837, 8545, 8558, 8567, 8576, 8577, 8579,
                                           8601, 8602, 8615, 8616, 8617, 8626, 8639, 8640, 8655, 8656, 8657, 8666, 8667,
                                           8668, 8669, 8670, 8671, 8672, 8674, 8675, 9867, 8685, 8686, 8687, 9868, 9869,
                                           9872, 9873, 9874, 9875, 9876, 9878, 13136, 13137, 13138, 13139, 8771, 8772,
                                           13144, 13145, 13146, 8802, 8803, 8804, 8805, 13148, 13149, 8813, 8814, 8815,
                                           8818, 8820, 8821, 8822, 8839, 8842, 8857, 8859, 8875, 8876, 8878, 8879, 8880,
                                           8881, 8903, 8904, 8905, 8906, 8907, 8908, 8909, 8915, 8916, 8919, 8949, 8950,
                                           8953, 8971, 8995, 9010, 9011, 9012, 9016, 9935, 9030, 9936, 9937, 9938, 9043,
                                           9044, 9045, 9046, 9048, 9050, 9051, 9052, 9068, 9069, 9083, 9084, 9085, 9086,
                                           9087, 9947, 9948, 9949, 9950, 9103, 9106, 9107, 9951, 9110, 9111, 9112, 9113,
                                           9114, 9115, 9116, 9118, 13210, 9121, 13211, 9127, 9129, 9130, 9131, 9132,
                                           9133, 9134, 9135, 9136, 13213, 13214, 9152, 13218, 13219, 13220, 9172, 13221,
                                           13223, 9968, 9969, 9210, 9212, 9225, 9228, 9229, 9230, 9231, 9232, 10136,
                                           9252, 9253, 9254, 9982, 9983, 9278, 9279, 10138, 9288, 9298, 9299, 9300,
                                           9301, 9302, 9303, 9304, 9305, 10140, 9339, 9342, 9343, 9344, 9345, 9346,
                                           9347, 9348, 9349, 9350, 9351, 9352, 9353, 9354, 9999, 9370, 9372, 9374, 9375,
                                           9376, 9377, 9378, 9379, 9380, 10142, 9395, 9396, 10143, 13725, 9416, 9417,
                                           9419, 9420, 9421, 9422, 10014, 9424, 9425, 9427, 9428, 9429, 9430, 9431,
                                           9432, 10015, 10016, 10017, 10144, 10018, 10019, 9459, 9460, 9461, 10145,
                                           9471, 9472, 9482, 9483, 9484, 9488, 10146, 9499, 9512, 9513, 9514, 9515,
                                           9516, 9517, 9518, 9519, 9520, 9521, 10147, 9529, 9538, 9539, 9540, 9541,
                                           10148, 9558, 9559, 9561, 10149, 9571, 9572, 9573, 9574, 9575, 9576, 9577,
                                           9578, 9579, 9580, 9582, 9585, 9586, 9587, 9588, 9589, 9590, 9591, 9592, 9593,
                                           9594, 9595, 9596, 9597, 9599, 9600, 9601, 9602, 9603, 9604, 9605, 9606, 9607,
                                           9608, 9609, 9610, 9611, 9612, 9613, 9614, 9615, 9616, 9617, 9618, 9619, 9650,
                                           9651, 9652, 10069, 10070, 10071, 10073, 1544, 1545, 1546, 9741, 1550, 1551,
                                           1562, 1563, 1564, 1565, 1566, 1567, 1568, 1569, 1570, 1571, 1572, 1573, 1574,
                                           1575, 1576, 1577, 1578, 1579, 1580, 1581, 1582, 1583, 1584, 1585, 1586, 1587,
                                           1588, 1589, 1590, 1591, 1592, 1593, 1594, 1595, 1596, 1597, 1598, 1599, 1600,
                                           1601, 1602, 1603, 1604, 1605, 1606, 1607, 1608, 1609, 1610, 1611, 1612, 1613,
                                           1614, 1615, 1616, 1617, 1618, 1619, 1620, 1621, 1622, 1623, 1624, 1625, 1626,
                                           1627, 1628, 1629, 1630, 1631, 1632, 1633, 1634, 1635, 1636, 1637, 1638, 1639,
                                           1640, 1641, 1642, 1643, 1644, 1645, 1646, 1647, 1648, 1649, 1650, 1651, 1652,
                                           1653, 1654, 1655, 1656, 1657, 1658, 1659, 1660, 1661, 1662, 1663, 1664, 1665,
                                           1666, 1667, 1668, 1669, 1670, 1671, 1672, 1673, 1674, 1675, 1676, 1677, 1678,
                                           1679, 1680, 1681, 1682, 1683, 1684, 1685, 1686, 1687, 1688, 1689, 1690, 1691,
                                           1692, 1693, 1694, 1695, 1696, 1697, 1698, 1699, 1700, 1701, 1702, 1703, 1704,
                                           1705, 1706, 1707, 1708, 1709, 1710, 1711, 1712, 1713, 1714, 1715, 1716, 1717,
                                           1718, 1719, 1720, 1721, 1722, 1723, 1724, 1725, 1726, 1727, 1728, 1729, 1730,
                                           1731, 1732, 1733, 1734, 1735, 1736, 1737, 1738, 1739, 1740, 1741, 1742, 1743,
                                           1744, 1745, 9934, 1747, 1748, 1749, 1750, 1751, 1752, 1753, 1754, 1755, 1756,
                                           1757, 1758, 1759, 1760, 1761, 1762, 1763, 1764, 1765, 1766, 1767, 1768, 1769,
                                           1770, 1771, 1772, 1773, 1774, 1775, 9966, 9967, 1778, 1779, 1780, 1781, 1782,
                                           1783, 1784, 1785, 1786, 1787, 1788, 1789, 1790, 1791, 1792, 1793, 1794, 1795,
                                           1796, 1797, 1798, 1799, 1800, 1801, 1803, 1804, 1805, 1806, 1807, 1808, 1809,
                                           1810, 1811, 1812, 1813, 1814, 1815, 1816, 1817, 1818, 1819, 1820, 1821, 1822,
                                           1823, 1824, 1825, 1826, 10013, 1828, 1829, 1830, 1831, 1832, 1833, 1834,
                                           1835, 1836, 1837, 1838, 1839, 1840, 1841, 1842, 1843, 1844, 1845, 1846, 1847,
                                           1848, 1849, 1850, 1851, 1852, 1853, 1854, 1855, 1856, 1857, 1858, 1859, 1860,
                                           1861, 1862, 1863, 1864, 1865, 1866, 1867, 10139, 1869, 1870, 1871, 1872,
                                           1873, 1874, 10141, 1876, 1877, 1878, 1879, 1880, 10068, 1882, 1883, 1884,
                                           1885, 1886, 1887, 1888, 10072, 1890, 1891, 1892, 1893, 1894, 1895, 1896,
                                           1897, 1898, 1899, 1900, 1901, 1902, 1903, 1904, 1905, 1906, 1907, 1908, 1909,
                                           1910, 1911, 1912, 1913, 1914, 1915, 1916, 1917, 1918, 1919, 1920, 10112,
                                           10150, 10115, 10116, 1926, 1927, 1928, 1929, 1930, 1931, 1932, 1933, 1934,
                                           1935, 1936, 1937, 1938, 1939, 1940, 1941, 1942, 1943, 1944, 1945, 1946, 1947,
                                           1948, 1949, 1950, 1951, 1952, 1953, 1954, 1955, 1956, 1957, 1958, 1959, 1960,
                                           1961, 1962, 1963, 1964, 1965, 1966, 1967, 10151, 10158, 1970, 1971, 1972,
                                           1973, 1974, 1975, 1979, 1980, 1981, 10172, 10173, 1985, 1986, 1987, 1988,
                                           1989, 1990, 1991, 1992, 1993, 1994, 1995, 10179, 1997, 1998, 2001, 10193,
                                           10195, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014,
                                           2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023, 2024, 2025, 2026, 2027,
                                           2028, 2029, 2030, 2031, 2032, 2033, 2034, 2035, 2036, 2043, 2044, 2045, 2046,
                                           2047, 2048, 10237, 2051, 2052, 2057, 2058, 2059, 2060, 2061, 2062, 10178,
                                           2064, 2065, 10255, 10180, 2068, 2069, 2070, 2071, 10256, 10257, 2074, 10258,
                                           10259, 2077, 2078, 2079, 2080, 10268, 2082, 2083, 2085, 2087, 2088, 2091,
                                           2097, 2098, 2100, 2101, 2102, 2103, 2104, 2106, 2107, 2108, 2109, 2110, 2111,
                                           2112, 2113, 2114, 2115, 2116, 2117, 2118, 2119, 2120, 2121, 2122, 2123, 2124,
                                           2125, 2126, 2127, 2134, 2136, 2138, 2139, 2140, 2141, 2142, 2143, 2144, 2145,
                                           10196, 2150, 2151, 2152, 2153, 2154, 2155, 2156, 2157, 10342, 2159, 10343,
                                           10344, 2165, 2166, 2167, 2168, 2169, 2170, 2171, 2174, 2181, 2182, 2186,
                                           2192, 2193, 2194, 10391, 2203, 2204, 10395, 10396, 10397, 10208, 2209, 10398,
                                           10399, 2212, 10400, 10402, 10403, 2216, 2217, 2218, 2219, 10404, 2221, 2222,
                                           10406, 10407, 10408, 10409, 2227, 2228, 2229, 2233, 2234, 2235, 2236, 2237,
                                           10214, 2243, 2244, 2249, 2250, 2251, 2252, 2253, 2254, 2255, 2256, 2257,
                                           2258, 2259, 2260, 2262, 2266, 2267, 2268, 2269, 2271, 2273, 2274, 2275, 2276,
                                           2277, 2278, 2279, 2280, 2281, 2282, 2283, 2284, 2285, 2286, 2287, 2288, 2289,
                                           2290, 2291, 2292, 2293, 2294, 2295, 2296, 2297, 2298, 2299, 2300, 2301, 2302,
                                           2303, 2304, 2305, 2306, 2307, 2308, 2309, 2310, 2311, 2312, 2313, 2314, 2315,
                                           2316, 2317, 2318, 2319, 2320, 2321, 2322, 2323, 2324, 2325, 2326, 2327, 2328,
                                           2329, 2330, 2331, 2332, 2333, 2334, 2335, 2336, 2337, 2338, 2339, 2340, 2341,
                                           2342, 2343, 2344, 2345, 2346, 2347, 2348, 2349, 2350, 2351, 2352, 2353, 2354,
                                           2355, 2356, 2357, 2358, 2359, 2360, 2361, 2362, 2363, 2364, 2365, 2366, 2367,
                                           2368, 2369, 2370, 2371, 2372, 2373, 2374, 2375, 2376, 2377, 2378, 2379, 2380,
                                           2381, 2382, 2383, 2384, 2385, 2386, 2387, 2388, 2389, 2390, 2391, 2392, 2393,
                                           2394, 2395, 2396, 2397, 2398, 2399, 2400, 2401, 2402, 2403, 2404, 2405, 2406,
                                           2407, 2408, 2409, 2410, 2411, 2412, 2413, 2414, 2415, 2416, 2417, 2418, 2419,
                                           2420, 2421, 2422, 2423, 2424, 2425, 2426, 2427, 2428, 2429, 2430, 2431, 2432,
                                           2433, 2434, 2435, 2436, 2437, 2438, 2439, 2440, 2441, 2442, 2443, 2444, 2445,
                                           2446, 2447, 2448, 2449, 2450, 2451, 2452, 2453, 2454, 2455, 2456, 2457, 2458,
                                           2459, 2460, 2461, 2462, 2463, 2464, 2465, 2466, 2467, 2468, 2469, 2470, 2471,
                                           2472, 2473, 2474, 2475, 2476, 2477, 2478, 2479, 2480, 2481, 2482, 2483, 2484,
                                           2485, 2486, 2487, 2488, 2489, 2490, 2491, 2492, 2493, 2494, 2495, 2496, 2497,
                                           2498, 2499, 2500, 2501, 2502, 2503, 2504, 2505, 2506, 2507, 2508, 2509, 2510,
                                           2511, 2512, 2513, 2514, 2515, 2516, 2517, 2518, 2519, 2520, 2521, 2522, 2523,
                                           2524, 2525, 2526, 2527, 2528, 2529, 2530, 2531, 2532, 2533, 2534, 2535, 2536,
                                           2537, 2538, 2539, 2540, 2541, 2542, 2543, 2544, 2545, 2546, 2547, 2548, 2549,
                                           2550, 2551, 2552, 2553, 2554, 2555, 2556, 2557, 2558, 2559, 2560, 2561, 2562,
                                           2563, 2564, 2565, 2566, 2567, 2568, 2569, 2570, 2571, 2572, 2573, 2574, 2575,
                                           2576, 2577, 2578, 2579, 2580, 2581, 2582, 2583, 2584, 2585, 2586, 2587, 2588,
                                           2589, 2590, 2591, 2592, 2593, 2594, 2595, 2596, 2597, 2598, 2599, 2600, 2601,
                                           2602, 2603, 2604, 2605, 2606, 2607, 2608, 2609, 2610, 2611, 2612, 2613, 2614,
                                           2615, 2616, 2617, 2618, 2619, 2620, 2621, 2622, 2623, 2624, 2625, 2626, 2627,
                                           2628, 2629, 2630, 2631, 2632, 2633, 2634, 2635, 2636, 2637, 2638, 2639, 2640,
                                           2641, 2642, 2643, 2644, 2645, 2646, 2647, 2648, 2649, 2650, 2651, 2652, 2653,
                                           2654, 2655, 2656, 2657, 2658, 2659, 2660, 2661, 2662, 2663, 2664, 2665, 2666,
                                           2667, 2668, 2669, 2670, 2671, 2672, 2673, 2674, 2675, 2676, 2677, 2678, 2679,
                                           2680, 2681, 2682, 2683, 2684, 2685, 2686, 2687, 2688, 2689, 2690, 2691, 2692,
                                           2693, 2694, 2695, 2696, 2697, 2698, 2699, 2700, 2701, 2702, 2703, 2704, 2705,
                                           2706, 2707, 2708, 2709, 2710, 2711, 2712, 2713, 2714, 2715, 2716, 2717, 2718,
                                           2719, 2720, 2721, 2722, 2723, 2724, 2725, 2726, 2727, 2728, 2729, 2730, 2731,
                                           2732, 2733, 2734, 2735, 2736, 2737, 2738, 2739, 2740, 2741, 2742, 2743, 2744,
                                           2745, 2746, 2747, 2748, 2749, 2750, 2751, 2752, 2753, 2754, 2755, 2756, 2757,
                                           2758, 2759, 2760, 2761, 2762, 2763, 2764, 2765, 2766, 2767, 2768, 2769, 2770,
                                           2771, 2772, 2773, 2774, 2775, 2776, 2777, 2778, 2779, 2780, 2781, 2782, 2783,
                                           2784, 2785, 2786, 2787, 2788, 2789, 2790, 2791, 2792, 2793, 2794, 2795, 2796,
                                           2797, 2798, 2799, 2800, 2801, 2802, 2803, 2804, 2805, 2806, 2807, 2808, 2809,
                                           2810, 2811, 2812, 2813, 2814, 2815, 2816, 2817, 2818, 2819, 2820, 2821, 2822,
                                           2823, 2824, 2825, 2826, 2827, 2828, 2829, 2830, 2831, 2832, 2833, 2834, 2835,
                                           2836, 2837, 2838, 2839, 2840, 2841, 2842, 2843, 2844, 2845, 2846, 2847, 2848,
                                           2849, 2850, 2851, 2852, 2853, 2854, 2855, 2856, 2857, 2858, 2859, 2860, 2861,
                                           2862, 2863, 2864, 2865, 2866, 2867, 2868, 2869, 2870, 2871, 2872, 2873, 2874,
                                           2875, 2876, 2877, 2878, 2879, 2880, 2881, 2882, 2883, 2884, 2885, 2886, 2887,
                                           2888, 2889, 2890, 2891, 2892, 2893, 2894, 2895, 2896, 2897, 2898, 2899, 2900,
                                           2901, 2902, 2903, 2904, 2905, 2906, 2907, 2908, 2909, 2910, 2911, 2912, 2913,
                                           2914, 2915, 2916, 2917, 2918, 2919, 2920, 2921, 2922, 2923, 2924, 2925, 2926,
                                           2927, 2928, 2929, 2930, 2931, 2932, 2933, 2934, 2935, 2936, 2937, 2938, 2939,
                                           2940, 2941, 2942, 2943, 2944, 2945, 2946, 2947, 2948, 2949, 2950, 2951, 2952,
                                           2953, 2954, 2955, 2956, 2957, 2958, 2959, 2960, 2961, 2962, 2963, 2964, 2965,
                                           2966, 2967, 2968, 2969, 2970, 2971, 2972, 2973, 2974, 2975, 2976, 2977, 2978,
                                           2979, 2980, 2981, 2982, 2983, 2984, 2985, 2986, 2987, 2988, 2989, 2990, 2991,
                                           2992, 2993, 2994, 2995, 2996, 2997, 2998, 2999, 3000, 3001, 3002, 3003, 3004,
                                           3005, 3006, 3007, 3008, 3009, 3010, 3011, 3012, 3013, 3014, 3015, 3016, 3017,
                                           3018, 3019, 3020, 3021, 3022, 3023, 3024, 3025, 3026, 3027, 3028, 3029, 3030,
                                           3031, 3032, 3033, 3034, 3035, 3036, 3037, 3038, 3039, 3040, 3041, 3042, 3043,
                                           3044, 3045, 3046, 3047, 3048, 3049, 3050, 3051, 3052, 3053, 3054, 3055, 3056,
                                           3057, 3058, 3059, 3060, 3061, 3062, 3063, 3064, 3065, 3066, 3067, 3068, 3069,
                                           3070, 3071, 3072, 3073, 3074, 3075, 3076, 3077, 3078, 3079, 3080, 3081, 3082,
                                           3083, 3084, 3085, 3086, 3087, 3088, 3089, 3090, 3091, 3092, 3093, 3094, 3095,
                                           3096, 3097, 3098, 3099, 3100, 3101, 3102, 3103, 3104, 3105, 3106, 3107, 3108,
                                           3109, 3110, 3111, 3112, 3113, 3114, 3115, 3116, 3117, 3118, 3119, 3120, 3121,
                                           3122, 3123, 3124, 3125, 3126, 3127, 3128, 3129, 3130, 3131, 3132, 3133, 3134,
                                           3135, 3136, 3137, 3138, 3139, 3140, 3141, 3142, 3143, 3144, 3145, 3146, 3147,
                                           3148, 3149, 3150, 3151, 3152, 3153, 3154, 3155, 3156, 3157, 3158, 3159, 3160,
                                           3161, 3162, 3163, 3164, 3165, 3166, 3167, 3168, 3169, 3170, 11360, 3172,
                                           3173, 3174, 3175, 3176, 3177, 3178, 3179, 3180, 3181, 3182, 3183, 3184, 3185,
                                           3186, 3187, 3188, 3189, 3190, 3191, 3192, 3193, 3194, 3195, 3196, 3197, 3198,
                                           3199, 3200, 3201, 3202, 3203, 3204, 3205, 3206, 3207, 3208, 3209, 3210,
                                           11395, 11396, 11397, 11398, 11399, 11402, 11404, 3218, 11405, 11406, 11407,
                                           11408, 11409, 3224, 11410, 11411, 11412, 11414, 11419, 11420, 11421, 3232,
                                           3233, 3234, 3235, 11422, 11423, 3238, 11452, 3262, 3266, 3267, 11459, 11460,
                                           11466, 11467, 11469, 11476, 11477, 11478, 11479, 3290, 3302, 3305, 11501,
                                           11503, 11504, 11505, 11506, 11507, 11508, 3317, 11509, 11510, 11511, 11512,
                                           11513, 11514, 11515, 11519, 3329, 11523, 11527, 11528, 11529, 11535, 11536,
                                           11537, 3355, 3357, 3359, 3360, 3366, 3372, 3374, 3375, 3376, 11566, 11567,
                                           3385, 3389, 3390, 3391, 3392, 11582, 11583, 11584, 3396, 11585, 3398, 11586,
                                           11587, 11588, 11589, 11590, 11591, 11592, 11595, 3407, 11596, 11597, 11598,
                                           11601, 11602, 11603, 11604, 11605, 11606, 11607, 11608, 11609, 11625, 11626,
                                           11627, 11628, 11629, 11630, 11633, 11634, 11636, 11637, 11638, 11639, 11640,
                                           11641, 13711, 11658, 11659, 11660, 11661, 11662, 3471, 3473, 11676, 11677,
                                           11678, 11679, 11680, 11681, 11682, 11683, 11684, 11685, 11700, 11701, 3511,
                                           11705, 11706, 11707, 11708, 11709, 11710, 11711, 11712, 11713, 11714, 11715,
                                           11716, 11717, 11718, 11719, 11740, 11741, 11742, 11743, 11744, 11745, 11746,
                                           11747, 11748, 11749, 11750, 11751, 11752, 10477, 11753, 13733, 11756, 3576,
                                           3577, 3578, 11772, 11773, 3582, 3583, 13738, 13739, 3592, 3596, 3599, 3600,
                                           3604, 3605, 3613, 3618, 3620, 11816, 11817, 3626, 10491, 11829, 11830, 11831,
                                           11832, 11833, 11834, 11835, 11836, 11837, 11838, 11839, 11840, 11841, 11842,
                                           11843, 3652, 3653, 3654, 11844, 3656, 11846, 11847, 11849, 11851, 11856,
                                           3665, 11857, 3667, 3668, 3669, 11861, 11862, 11863, 11864, 11865, 3675, 3676,
                                           11867, 11868, 3679, 11870, 11871, 11872, 11873, 11874, 11875, 11876, 11877,
                                           11878, 11879, 11880, 11881, 11882, 11883, 11888, 11889, 3698, 3699, 3700,
                                           3701, 3704, 3705, 10506, 3711, 3720, 3722, 3723, 3727, 3730, 3731, 11924,
                                           11925, 3737, 3741, 3745, 3747, 3748, 3762, 3763, 3764, 3765, 11954, 11955,
                                           11956, 11957, 11958, 11959, 3772, 10519, 11960, 11961, 11963, 11964, 11971,
                                           11972, 11973, 3782, 3783, 11974, 11975, 3786, 10522, 3788, 11976, 11977,
                                           11978, 3792, 3793, 3794, 3795, 3796, 3797, 11981, 11982, 3800, 11986, 3802,
                                           11987, 3804, 3805, 11989, 3807, 3808, 3809, 11993, 11994, 11995, 11996, 3814,
                                           11998, 11999, 3817, 3818, 12002, 12003, 12004, 3822, 3823, 3824, 12008,
                                           12009, 3827, 3828, 12012, 12014, 12015, 12023, 3834, 3835, 12038, 12039,
                                           12040, 12041, 12042, 12043, 12044, 3854, 12046, 3856, 3857, 10536, 3859,
                                           3860, 3861, 3862, 10537, 12054, 12056, 12057, 3867, 3868, 3869, 3870, 3871,
                                           12058, 12059, 12060, 12061, 3880, 12077, 12078, 12079, 12080, 12081, 3897,
                                           12092, 12093, 3905, 12102, 12103, 12104, 12105, 12106, 12108, 12109, 12110,
                                           12111, 3920, 3921, 12112, 12113, 12114, 12115, 12116, 12117, 12118, 12119,
                                           3930, 3931, 12120, 12121, 12122, 3935, 12123, 12124, 12125, 12126, 12127,
                                           12128, 12129, 12130, 12131, 12132, 12133, 12134, 12135, 12136, 12137, 12138,
                                           12139, 12140, 12141, 12142, 3964, 12156, 12157, 12158, 12159, 12160, 12161,
                                           12162, 3972, 12163, 12164, 12165, 12166, 12168, 12169, 12170, 3993, 3995,
                                           3997, 3998, 4002, 4003, 4004, 4005, 4018, 4019, 4020, 4021, 4022, 4024, 4025,
                                           4026, 4028, 4029, 4030, 12220, 12227, 4037, 4038, 12230, 12231, 4041, 4042,
                                           12232, 10573, 12233, 12234, 12235, 12236, 10574, 12237, 4051, 4052, 12238,
                                           10575, 12239, 12240, 4057, 4058, 4059, 4061, 12253, 4063, 4065, 4066, 4067,
                                           4068, 4069, 4070, 4071, 4072, 4073, 4074, 4076, 4077, 4078, 4082, 12277,
                                           4090, 12284, 4093, 4094, 12285, 12286, 12287, 12288, 12289, 4100, 12290,
                                           12291, 4108, 4109, 4110, 4111, 4112, 4114, 4115, 4116, 4117, 4118, 4122,
                                           10589, 4134, 4137, 4148, 4149, 4151, 4152, 4153, 4154, 4155, 12347, 4157,
                                           12350, 12351, 4160, 4161, 4162, 12352, 10260, 12353, 4166, 12354, 4168, 4169,
                                           4170, 12355, 4172, 4173, 4187, 4188, 10261, 4191, 4192, 12385, 12386, 4195,
                                           4196, 4197, 4198, 12387, 4200, 4201, 4202, 12389, 12390, 4205, 4206, 4207,
                                           4208, 4209, 4210, 12394, 4212, 4213, 10262, 12398, 12399, 4217, 12401, 4220,
                                           4221, 4222, 4223, 4224, 4225, 4226, 12419, 4228, 4229, 12420, 4231, 4232,
                                           4233, 12421, 4239, 4240, 4241, 12241, 4245, 4247, 4248, 12440, 12441, 12442,
                                           12443, 12444, 12445, 12446, 10618, 4271, 12462, 12463, 4274, 4275, 4276,
                                           4277, 4278, 4279, 10619, 4281, 4282, 4283, 4284, 10620, 10621, 4287, 12480,
                                           12481, 4290, 10622, 12484, 4293, 4294, 10623, 4296, 4297, 12485, 12486, 4300,
                                           12487, 4302, 4303, 4304, 4306, 4307, 10625, 4310, 4311, 10626, 12506, 4315,
                                           10627, 4317, 4318, 12510, 4320, 4321, 4322, 10628, 12511, 4325, 10629, 4327,
                                           4328, 12512, 12514, 10630, 4332, 4333, 12517, 12518, 4336, 4337, 4338, 4339,
                                           10631, 4341, 10632, 4343, 4344, 4345, 10633, 12533, 4348, 12534, 4350, 4351,
                                           4352, 4353, 4354, 4355, 4356, 4357, 4358, 10634, 10635, 12545, 12546, 12547,
                                           12548, 4367, 4369, 4370, 4377, 4378, 4379, 4381, 4382, 12578, 4387, 4388,
                                           4389, 4393, 4394, 4396, 4398, 4403, 4404, 4405, 12595, 4407, 12596, 4410,
                                           12614, 4424, 4427, 4429, 4430, 10650, 4434, 4436, 4437, 4438, 4439, 10651,
                                           10652, 4442, 12629, 12631, 12632, 4446, 4447, 4448, 12633, 12634, 4452, 4456,
                                           4457, 4458, 4459, 4460, 4461, 4462, 4463, 12651, 4465, 4466, 4467, 12652,
                                           4469, 4470, 4471, 4472, 4473, 4475, 4476, 4477, 4478, 4479, 4480, 4481, 4482,
                                           4483, 4484, 12670, 12672, 12673, 12674, 12675, 12676, 4495, 4496, 4497, 4499,
                                           4502, 4510, 4512, 4513, 4514, 4515, 4516, 4517, 4518, 4519, 4520, 4521, 4522,
                                           12707, 4524, 4525, 4527, 4528, 4529, 4530, 4531, 4532, 4534, 4535, 4536,
                                           12740, 12741, 4550, 12742, 4552, 4553, 4554, 12744, 12745, 4557, 4558, 12746,
                                           4560, 12747, 4562, 4563, 12748, 12749, 12750, 12751, 12752, 12753, 12754,
                                           12755, 12759, 12760, 12761, 12763, 12764, 4577, 4578, 12765, 4580, 12766,
                                           12767, 4583, 4584, 12768, 4586, 4587, 10681, 12775, 4590, 12776, 12777, 4593,
                                           12779, 4595, 12795, 12796, 12825, 4645, 4646, 4647, 4652, 4657, 12853, 4662,
                                           12854, 12855, 12856, 12857, 4670, 4682, 4685, 4686, 4687, 4691, 4692, 4694,
                                           4695, 4696, 4697, 12887, 4699, 12892, 4702, 12895, 12896, 12897, 12898, 4715,
                                           4718, 12913, 4722, 4723, 4724, 4725, 12914, 12915, 10709, 4729, 4730, 10710,
                                           4758, 4763, 12972, 12973, 4795, 12988, 4797, 12989, 12990, 12991, 12992,
                                           12994, 4803, 12995, 12996, 12997, 12356, 13015, 4826, 4827, 4833, 4835, 4837,
                                           4838, 13031, 4840, 13032, 13033, 13034, 13035, 4845, 13036, 4847, 13037,
                                           13038, 13039, 13040, 13041, 13042, 13043, 13044, 13045, 4860, 4865, 4872,
                                           4874, 4875, 4876, 4877, 4878, 4879, 10739, 4881, 4882, 4883, 4884, 13074,
                                           13075, 4887, 13076, 4889, 13077, 13092, 13093, 4902, 13094, 13095, 4905,
                                           13096, 13097, 4908, 13098, 13099, 4911, 4912, 13100, 13102, 4915, 4916,
                                           13103, 4918, 13104, 4923, 4928, 4929, 4930, 13122, 4932, 13123, 13125, 4935,
                                           13126, 4937, 13127, 4939, 13128, 4941, 4942, 4943, 13129, 13130, 4946, 13131,
                                           13132, 13133, 13134, 4951, 13135, 4953, 4954, 4955, 10754, 13140, 13142,
                                           13143, 4960, 4961, 4962, 4963, 4964, 10755, 10756, 4968, 4969, 10757, 13165,
                                           13166, 10758, 13167, 13169, 4978, 4979, 4980, 10759, 13170, 13173, 13174,
                                           10760, 13175, 13176, 10761, 10762, 12391, 13191, 5003, 5004, 5007, 5009,
                                           5012, 13206, 5015, 5016, 10766, 5018, 12395, 10767, 13207, 13208, 13209,
                                           5024, 10768, 5026, 12396, 5028, 13212, 5030, 5031, 13215, 13216, 13217, 5035,
                                           10770, 5037, 5038, 13222, 10771, 13226, 13228, 13229, 5044, 10772, 12400,
                                           13231, 13232, 13233, 10773, 13234, 13239, 5053, 13240, 10774, 5056, 5057,
                                           10775, 5062, 5063, 13255, 10776, 13256, 13257, 13258, 13259, 5070, 10777,
                                           13260, 10778, 5078, 10779, 5081, 5082, 5085, 5087, 13290, 13293, 13296,
                                           13300, 13304, 13319, 13326, 13327, 13328, 13329, 13332, 13333, 13337, 13338,
                                           13339, 13341, 13342, 13343, 5152, 5153, 13344, 13345, 13346, 5157, 5158,
                                           5159, 13347, 13350, 13351, 13352, 13353, 5165, 5166, 13358, 13359, 13361,
                                           13362, 13363, 5172, 13364, 5174, 13366, 13367, 5179, 5188, 13385, 13386,
                                           13387, 13388, 13391, 5200, 13392, 5210, 5211, 5212, 13411, 13412, 13413,
                                           13414, 13415, 13416, 5225, 5226, 5227, 5228, 5229, 5233, 5235, 5238, 13430,
                                           5245, 13438, 5247, 5248, 5249, 13442, 13445, 13446, 13448, 13449, 13450,
                                           13451, 13452, 13453, 5262, 13454, 13455, 13461, 13462, 13465, 13467, 13468,
                                           13469, 13470, 13471, 13472, 13473, 5282, 13474, 13475, 5291, 13491, 5300,
                                           5302, 5303, 13506, 5316, 5317, 13508, 5319, 13509, 13510, 13512, 13513, 5327,
                                           5330, 5333, 13528, 13529, 13530, 13531, 13532, 5341, 13534, 13536, 13537,
                                           13538, 13540, 13541, 13542, 5351, 5353, 13564, 5364, 13557, 12464, 5367,
                                           5368, 13559, 5370, 12465, 5372, 5373, 5374, 10837, 13560, 13561, 5378, 13563,
                                           5380, 5381, 5382, 5383, 10839, 13568, 13569, 10840, 5388, 13565, 5390, 10841,
                                           13586, 5395, 5396, 5397, 10842, 13588, 10843, 10844, 5408, 5409, 5410, 13603,
                                           5412, 5413, 10845, 13566, 13604, 5417, 13605, 13606, 13607, 13608, 13609,
                                           13610, 13611, 13612, 13613, 13614, 13615, 13616, 5430, 13617, 5432, 5433,
                                           13618, 13619, 13620, 13567, 13621, 13622, 13623, 13624, 13625, 13626, 13627,
                                           13632, 13633, 13634, 13635, 5455, 13650, 13651, 13652, 13653, 13654, 13655,
                                           13656, 13657, 13658, 13659, 13660, 13661, 13662, 13663, 13664, 13665, 13666,
                                           13667, 13668, 5478, 13670, 13671, 13672, 13673, 13674, 13675, 13676, 5486,
                                           5487, 13677, 13678, 13679, 13680, 13681, 13682, 13683, 13684, 5496, 13685,
                                           13686, 13687, 13688, 5501, 13689, 13690, 5504, 13691, 13692, 13693, 5508,
                                           13694, 13695, 13696, 13697, 13698, 13699, 13700, 13701, 13702, 5518, 13703,
                                           13704, 13705, 5522, 13706, 13707, 13708, 13709, 13710, 5528, 13712, 13713,
                                           13714, 5532, 5533, 13719, 5535, 5536, 13720, 13721, 13722, 13723, 13724,
                                           13571, 13726, 13727, 13728, 13729, 13730, 13731, 13732, 5550, 5551, 13735,
                                           13736, 13737, 5555, 5556, 13740, 13741, 13742, 13743, 13745, 13746, 13747,
                                           13748, 13749, 13750, 13751, 13752, 13753, 13754, 13759, 13760, 13762, 13763,
                                           13764, 13765, 13766, 13767, 13768, 13769, 13770, 13771, 13772, 5584, 5585,
                                           5592, 5595, 5599, 5601, 5602, 5604, 5605, 5606, 5615, 5617, 5620, 5622,
                                           12515, 5624, 5625, 5627, 12516, 10888, 10889, 5637, 10890, 5640, 10891, 5647,
                                           5648, 5649, 5650, 5651, 5652, 5654, 5656, 5658, 5659, 5662, 5667, 5668, 5671,
                                           5675, 5676, 5683, 5685, 5688, 5689, 5690, 5697, 5698, 5699, 5702, 5707, 5709,
                                           5711, 5713, 5716, 10906, 12535, 12536, 5729, 5733, 12537, 5736, 5738, 5739,
                                           5740, 5741, 12538, 12539, 5746, 5748, 12540, 5752, 5753, 12541, 5755, 5756,
                                           5757, 12542, 5770, 5771, 5773, 5774, 5776, 5779, 5781, 5784, 5785, 5786,
                                           5788, 5791, 5793, 5794, 5795, 10921, 5797, 5799, 5800, 5803, 5804, 5806,
                                           5807, 5808, 5814, 5831, 5840, 5841, 5844, 5845, 10931, 5850, 5855, 5864,
                                           5867, 5868, 10951, 10957, 10958, 10959, 10960, 10962, 10963, 10964, 10965,
                                           10966, 10967, 10968, 10969, 10970, 10971, 10972, 10973, 10978, 10982, 10997,
                                           10998, 10999, 11000, 11003, 11005, 11006, 12653, 11028, 11033, 11034, 11050,
                                           11979, 11980, 6507, 6509, 6510, 6514, 6541, 6542, 6543, 6565, 6566, 6572,
                                           12705, 6600, 6601, 6630, 11095, 11988, 11101, 6704, 11104, 6720, 11105,
                                           11990, 11991, 6765, 11992, 6805, 6807, 6808, 6810, 6811, 6812, 6814, 6830,
                                           6833, 6838, 6884, 6885, 6886, 6888, 6890, 6891, 6892, 6893, 11997, 12769,
                                           12770, 6907, 11145, 6935, 6936, 6937, 6938, 6967, 6972, 6986, 6996, 6997,
                                           6998, 6999, 7000, 7001, 12001, 7016, 7017, 7021, 7023, 7024, 7026, 7027,
                                           7028, 7029, 7030, 11166, 11167, 7038, 11168, 7053, 7064, 7065, 7066, 7071,
                                           7072, 7073, 7074, 7075, 7076, 7078, 7081, 7082, 7084, 7086, 7087, 7090, 7094,
                                           7095, 7096, 7097, 7098, 7101, 7102, 12005, 7106, 7107, 7108, 7109, 7110,
                                           7111, 7123, 7130, 12006, 7136, 7137, 7138, 7139, 7140, 7141, 7142, 7144,
                                           7150, 7151, 7152, 7153, 7154, 7155, 7156, 12007, 7159, 7160, 11195, 7177,
                                           7178, 7179, 7180, 7181, 7182, 7183, 7184, 7185, 7186, 7187, 7188, 7206, 7223,
                                           7224, 7225, 7226, 7227, 7228, 12010, 7232, 7246, 7247, 7248, 7249, 7250,
                                           7251, 7252, 7253, 7254, 7255, 12011, 7263, 7264, 7265, 7266, 7267, 7268,
                                           7269, 7270, 7271, 7272, 7273, 11215, 7275, 7276, 7279, 7280, 7282, 7283,
                                           7284, 7285, 11217, 11218, 7293, 7300, 7301, 7305, 7310, 7324, 7325, 7335,
                                           7336, 7337, 7338, 7339, 7341, 7342, 7351, 7352, 7373, 7382, 7383, 7384, 7385,
                                           11237, 7389, 7391, 7392, 7393, 7394, 7395, 7408, 7410, 7411, 7412, 7413,
                                           7417, 7418, 7419, 7420, 7421, 7422, 7423, 7424, 7425, 7433, 7434, 7436, 7437,
                                           7438, 7440, 7444, 7445, 7446, 7447, 7448, 11253, 11254, 7481, 7482, 7483,
                                           7485, 7498, 7499, 7500, 7501, 7502, 7503, 7514, 7515, 7541, 7542, 7543, 7544,
                                           7545, 7547, 7548, 7549, 7550, 7551, 7552, 7554, 7555, 7557, 7567, 7568, 7569,
                                           7570, 7571, 7574, 7578, 7579, 7580, 7581, 7582, 7585, 7587, 7588, 7589, 7591,
                                           7592, 7593, 7594, 7599, 7620, 7621, 7622, 7628, 7629, 7630, 7631, 7632, 7656,
                                           7659, 7660, 7681, 7682, 7683, 7684, 7685, 7708, 7710, 7711, 7712, 7713, 7714,
                                           7715, 7716, 7717, 7727, 7755, 7756, 7757, 7761, 7762, 7763, 7764, 7778, 7779,
                                           7780, 7782, 7783, 7784, 7785, 7786, 7787, 7788, 7789, 7803, 7804, 7805,
                                           10405, 7826, 7827, 7828, 7829, 7830, 7831, 7832, 7833, 7834, 7835, 7836,
                                           7837, 7853, 7880, 7899, 7913, 7914, 7915, 7916, 7917, 7918, 7928, 11348,
                                           7945, 11349, 7954, 7955, 7956, 7957, 7998, 7999, 8000, 8002, 8003, 8004,
                                           8005, 8011, 8013, 8014, 8029, 8030, 8031, 8032, 8036, 8054, 8060, 8061, 8074,
                                           8099, 8100, 8101, 11382, 11383, 8120, 11384, 11385, 10092, 8145, 8155, 10093,
                                           8161, 11393, 10094]
                    , res))
                # 如果数据存在
                if res:
                    self.handler_data(insert_db, res)
                    count += len(res)
                    INFO.logger.info(f"thread_id={threading.current_thread().ident}  "
                                     f"AddTime_start={AddTime_start}   "
                                     f"AddTime_end={AddTime_end}   "
                                     f"验证数据量为{count}  ")
                else:
                    continue
            else:
                break

    def handler_data(self, insert_db, res):

        # res = list(map(lambda x: (x[0],x[1],x[2],x[3]),res))
        allocation_bill_data = list(filter(lambda x: x[7] in [4, 5], res))
        if allocation_bill_data:
            self.insert_allocation_bill_data(insert_db, allocation_bill_data)
        inventory_check_order_data = list(filter(lambda x: x[7] in [6, 7], res))
        if inventory_check_order_data:
            self.insert_inventory_check_order_data(insert_db, inventory_check_order_data)
        other_order_data = list(filter(lambda x: x[7] in [1, 3], res))
        if other_order_data:
            self.insert_other_order_data(insert_db, other_order_data)
        procurement_putin_data = list(filter(lambda x: x[7] == 0, res))
        if procurement_putin_data:
            self.insert_procurement_putin_data(insert_db, procurement_putin_data)
        sales_putout_data = list(filter(lambda x: x[7] == 2, res))
        if sales_putout_data:
            self.insert_sales_putout_data(insert_db, sales_putout_data)
        supplier_returns_order = list(filter(lambda x: x[7] == 8, res))
        if supplier_returns_order:
            self.insert_supplier_returns_order(insert_db, supplier_returns_order)

    def insert_allocation_bill_data(self, insert_db, allocation_bill_data):
        insert_sql = """
        INSERT IGNORE INTO znkdceshilog.allocation_bill (BillNumber,AllocationOrderNo,ToWarehouseId,SKU) VALUES (%s,%s,%s,%s);
        """
        allocation_bill_data = list(map(lambda x: (x[0], x[1], x[2], x[3]), allocation_bill_data))
        rows = insert_db.execute_many(insert_sql, allocation_bill_data)
        if rows == 0:
            ERROR.logger.error(f"""INSERT IGNORE INTO zhcxkj_datacenter.allocation_bill 
            (BillNumber,AllocationOrderNo,ToWarehouseId,SKU) VALUES (%s,%s,%s,%s);插入失败
            data = {allocation_bill_data}
                """)

    def insert_inventory_check_order_data(self, insert_db, inventory_check_order_data):
        insert_sql = """
        INSERT IGNORE INTO znkdceshilog.inventory_check_order (CustomerId,BillNumber,OrderNo,WarehouseId,SKU) VALUES (1,%s,%s,%s,%s);
        """
        inventory_check_order_data = list(map(lambda x: (x[0], x[1], x[2], x[3]), inventory_check_order_data))
        rows = insert_db.execute_many(insert_sql, inventory_check_order_data)
        if rows == 0:
            ERROR.logger.error(f"""
            INSERT IGNORE INTO znkdceshilog.inventory_check_order (CustomerId,BillNumber,OrderNo,WarehouseId,SKU) VALUES (1,%s,%s,%s,%s);
            插入失败
            data = {inventory_check_order_data}
                """)

    def insert_other_order_data(self, insert_db, other_order_data):
        insert_sql = """
        INSERT IGNORE INTO znkdceshilog.other_order (CustomerId,BillNumber,OrderNo,WareHouseId,SKU) VALUES (1,%s,%s,%s,%s);

        """
        other_order_data = list(map(lambda x: (x[0], x[1], x[2], x[3]), other_order_data))
        rows = insert_db.execute_many(insert_sql, other_order_data)
        if rows == 0:
            ERROR.logger.error(f"""
            INSERT IGNORE INTO znkdceshilog.other_order (CustomerId,BillNumber,OrderNo,WareHouseId,SKU) VALUES (1,%s,%s,%s,%s);
            插入失败
            data = {other_order_data}
                """)

    def insert_procurement_putin_data(self, insert_db, procurement_putin_data):
        insert_sql = """
        INSERT IGNORE INTO znkdceshilog.procurement_putin (CustomerId,BillNumber,VerificationOrderNo,WarehouseId,SKU) VALUES (1,%s,%s,%s,%s);

        """
        procurement_putin_data = list(map(lambda x: (x[0], x[1], x[2], x[3]), procurement_putin_data))
        rows = insert_db.execute_many(insert_sql, procurement_putin_data)
        if rows == 0:
            ERROR.logger.error(f"""
            INSERT IGNORE INTO znkdceshilog.procurement_putin (CustomerId,BillNumber,VerificationOrderNo,WarehouseId,SKU) VALUES (1,%s,%s,%s,%s);
            插入失败
            data = {procurement_putin_data}
                """)

    def insert_sales_putout_data(self, insert_db, sales_putout_data):
        insert_sql = """
        INSERT IGNORE INTO znkdceshilog.sales_putout (CustomerId,BillNumber,ClientOrderNo,WareHouseId,SKU) VALUES (1,%s,%s,%s,%s);

        """
        sales_putout_data = list(map(lambda x: (x[0], x[1], x[2], x[3]), sales_putout_data))
        rows = insert_db.execute_many(insert_sql, sales_putout_data)
        if rows == 0:
            ERROR.logger.error(f"""
            INSERT IGNORE INTO znkdceshilog.sales_putout (CustomerId,BillNumber,ClientOrderNo,WareHouseId,SKU) VALUES (1,%s,%s,%s,%s);
            插入失败
            data = {sales_putout_data}
                """)

    def insert_supplier_returns_order(self, insert_db, supplier_returns_order):
        insert_sql = """
        INSERT IGNORE INTO znkdceshilog.supplier_returns_order (CustomerId,BillNumber,OrderNo,WarehouseId,SKU) VALUES (1,%s,%s,%s,%s);

        """
        supplier_returns_order = list(map(lambda x: (x[0], x[1], x[2], x[3]), supplier_returns_order))
        rows = insert_db.execute_many(insert_sql, supplier_returns_order)
        if rows == 0:
            ERROR.logger.error(f"""
            INSERT IGNORE INTO znkdceshilog.supplier_returns_order (CustomerId,BillNumber,OrderNo,WarehouseId,SKU) VALUES (1,%s,%s,%s,%s);
            插入失败
            data = {supplier_returns_order}
                """)


if __name__ == '__main__':
    # TestChange().test_allocation_bill()
    t = TestChange()
    time_list = [('2023-08-01 00:00:00', '2023-08-01 23:59:59'), ('2023-08-02 00:00:00', '2023-08-02 23:59:59'),
                 ('2023-08-03 00:00:00', '2023-08-03 23:59:59'), ('2023-08-04 00:00:00', '2023-08-04 23:59:59'),
                 ('2023-08-05 00:00:00', '2023-08-05 23:59:59'), ('2023-08-06 00:00:00', '2023-08-06 23:59:59'),
                 ('2023-08-07 00:00:00', '2023-08-07 23:59:59'), ('2023-08-08 00:00:00', '2023-08-08 23:59:59'),
                 ('2023-08-09 00:00:00', '2023-08-09 23:59:59'), ('2023-08-10 00:00:00', '2023-08-10 23:59:59'),
                 ('2023-08-11 00:00:00', '2023-08-11 23:59:59'), ('2023-08-12 00:00:00', '2023-08-12 23:59:59'),
                 ('2023-08-13 00:00:00', '2023-08-13 23:59:59'), ('2023-08-14 00:00:00', '2023-08-14 23:59:59'),
                 ('2023-08-15 00:00:00', '2023-08-15 23:59:59'), ('2023-08-16 00:00:00', '2023-08-16 23:59:59'),
                 ('2023-08-17 00:00:00', '2023-08-17 23:59:59'), ('2023-08-18 00:00:00', '2023-08-18 23:59:59'),
                 ('2023-08-19 00:00:00', '2023-08-19 23:59:59'), ('2023-08-20 00:00:00', '2023-08-20 23:59:59'),
                 ('2023-08-21 00:00:00', '2023-08-21 23:59:59'), ('2023-08-22 00:00:00', '2023-08-22 23:59:59'),
                 ('2023-08-23 00:00:00', '2023-08-23 23:59:59'), ('2023-08-24 00:00:00', '2023-08-24 23:59:59'),
                 ('2023-08-25 00:00:00', '2023-08-25 23:59:59'), ('2023-08-26 00:00:00', '2023-08-26 23:59:59'),
                 ('2023-08-27 00:00:00', '2023-08-27 23:59:59'), ('2023-08-28 00:00:00', '2023-08-28 23:59:59'),
                 ('2023-08-29 00:00:00', '2023-08-29 23:59:59'), ('2023-08-30 00:00:00', '2023-08-30 23:59:59'),
                 ('2023-08-31 00:00:00', '2023-08-31 23:59:59')]
    executor = ThreadPoolExecutor(max_workers=8)
    tasks = []
    for i in range(len(time_list)):
        # 使用funools.partial函数创建一个新的函数，将参数绑定到函数中
        new_task = partial(t.test_allocation_bill, time_list[i][0], time_list[i][1])
        # executor.submit(new_task)
        tasks.append(executor.submit(new_task))

    # 处理已完成的任务
    # for future in as_completed(tasks):
    #     try:
    #         result = future.result()
    #         # 处理任务执行的结果
    #         print(result)
    #     except Exception as e:
    #         # 处理任务执行出的异常
    #         print(f"任务{i}执行出现异常，参数为{new_task.args}")
    #         raise

    # 关闭线程池
    executor.shutdown()
